package com.hllxd.hism.star.basic.service.service.rock;

import com.hllxd.hism.star.basic.service.beans.CostOverviewBO;
import com.hllxd.hism.star.basic.service.dao.mapper.doris.OwnerHealthInfoMapper;
import com.hllxd.hism.star.basic.service.model.doris.BillingOwnerEntity;
import com.hllxd.hism.star.basic.service.model.doris.OwnerHealthInfoEntity;
import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author wugaungxi
 * @Description
 * @Date 2024/5/7 17:12
 */
@Service
public class CostOverviewService {
    @Autowired
    private BillingOwnerService billingOwnerService;
    @Autowired
    private OwnerHealthInfoMapper ownerHealthInfoMapper;

    public CostOverviewBO findCostOverview(String dt, String oa){
        if(Strings.isEmpty(dt) || Strings.isEmpty(oa)){
            return null;
        }
        OwnerHealthInfoEntity ownerHealthInfoEntity = ownerHealthInfoMapper.findByDtAndOa(dt, oa);
        List<BillingOwnerEntity> billingOwnerEntityList = billingOwnerService.findByDtAndOa(dt, oa);
        if(ownerHealthInfoEntity == null){
            return null;
        }
        CostOverviewBO costOverviewBO = new CostOverviewBO();
        costOverviewBO.setDt(ownerHealthInfoEntity.getDt());
        costOverviewBO.setOwnerId(ownerHealthInfoEntity.getOwnerId());
        costOverviewBO.setTaskScore(ownerHealthInfoEntity.getTotalTaskScore());
        costOverviewBO.setStorageScore(ownerHealthInfoEntity.getTotalStorageScore());
        costOverviewBO.setBillingOwnerEntityList(billingOwnerEntityList);
        return costOverviewBO;
    }

}
